package yb.ecp.fast.user.infra;

import yb.ecp.fast.infra.infra.ActionResult;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by john on 2017/4/11.
 */
public class BasicController {
    public <T> ActionResult<T> actionResult(ErrorCode code, T value){
        return  new ActionResult<T>(code.getCode(),
                code.getDesc(),
                value);
    }
    public <T> ActionResult<T> actionResult(T value){
        ErrorCode code = ErrorCode.Success;
        return  actionResult(code,value);
    }

    public ActionResult actionResult(ErrorCode code){
        return  actionResult(code,null);
    }

    public String getUserId(HttpServletRequest request){
        String userId = request.getHeader("x-user-id");
        return userId;
    }

}
